Date: Sun, 24 Nov 1996 23:08:52 GMT
Server: NCSA/1.5
Content-type: text/html
Last-modified: Wed, 03 Jul 1996 20:04:20 GMT
Content-length: 3635

<html>
<head>
<TITLE>Shadow Tip</TITLE> 
</head>


<body>
<!WA0><!WA0><!WA0><!WA0><!WA0><!WA0><!WA0><!WA0><!WA0><!WA0><!WA0><!WA0><!WA0><!WA0><!WA0><!WA0><img src="http://www.tc.cornell.edu:80/DX/DXTIPS/shadow.image.gif">
<p>
<h2>
Making Shadows.
</h2>
<p>
<hr>
<p>
Shadows are powerful perceptual cues for the 3D relationship of objects
in a scene. The DX renderer does not produce shadows, but is possible
to generate acceptable shadows by modifying the colors of individual
vertices of objects in a scene. The macro described here performs the
following steps:
<ul>
<li> The obects to be shadowed are transformed to the coordinate system
of a light places in an arbitrary direction at infinity.
<li> A depth buffer is calculated from the viewpoint of the light.
<li> The depth buffer is turned into a "volume" data set by stacking it
with itself in such a way that it overlaps all the vertices in the
original objects.
<li> The volume depth buffer is mapped onto the original vertices as new data.
<li> The depth buffer value at each vertex is compared to the depth at
of the vertex. If the vertex is farther from the light than the value
given by the depth buffer, it is dimmed.
<li> The objects (with modified colors) are transformed back to world coordinates.
</ul>
This approach (a sort of vertex-mapped, z-buffer method) has some limitations:
<ul>
<li> The accuracy of the shadows depends on the density of vertices on
an object. Objects with just a few vertices will have "jaggie" shadows thrown onto them. 
<li> The resolution of the depth buffer must be high to get acceptable 
shadows.
<li> The Compute module cannot resolve transform objects. Any objects
built using Rotate, Translate, Scale, or Transform modules will not
shadow correctly, unless you use the 
<!WA1><!WA1><!WA1><!WA1><!WA1><!WA1><!WA1><!WA1><!WA1><!WA1><!WA1><!WA1><!WA1><!WA1><!WA1><!WA1><a href="http://www.tc.cornell.edu:80/DX/DXTIPS/calculate.html"> Calculate </a>
macro to 
apply the transforms.
<li> The module uses a <b> lot </b> of memory. It runs well on a machine with
.5 Gbyte of memory.
</ul>
<p>
The macro dialog box is shown below. 
<br>
Explaination of inputs:
<ol>
<li> The object input carries the objects to be shadowed against each other.
<li> The depth_resolution input is the resolution of the desired depth-buffer.
<li> The shadow_factor is the amount to "dim" a shadowed vertex.
<li> The light_pos is the direction to the light at infinity.
<li> The depth_ingore input is the threshold for self-shadowing. Set to
zero, it will cause surfaces to "dim" themselves.
<li> The object_scale input overrides the automatic conversion of the object
size to camera coordinate space.
<li> The offset input allows the objects to move along the z-axis of the light.
</ol>
<p>
<!WA2><!WA2><!WA2><!WA2><!WA2><!WA2><!WA2><!WA2><!WA2><!WA2><!WA2><!WA2><!WA2><!WA2><!WA2><!WA2><img src="http://www.tc.cornell.edu:80/DX/DXTIPS/shadow.module.dialog.gif">
<p>
To download the test program click 
<!WA3><!WA3><!WA3><!WA3><!WA3><!WA3><!WA3><!WA3><!WA3><!WA3><!WA3><!WA3><!WA3><!WA3><!WA3><!WA3><a href="http://www.tc.cornell.edu:80/DX/DXTIPS/shadow.net">
here. </a>. You also need it's configuration file   
<!WA4><!WA4><!WA4><!WA4><!WA4><!WA4><!WA4><!WA4><!WA4><!WA4><!WA4><!WA4><!WA4><!WA4><!WA4><!WA4><a href="http://www.tc.cornell.edu:80/DX/DXTIPS/shadow.cfg"> from here.</a>
<p>
The test program layout is shown 
<!WA5><!WA5><!WA5><!WA5><!WA5><!WA5><!WA5><!WA5><!WA5><!WA5><!WA5><!WA5><!WA5><!WA5><!WA5><!WA5><a href="http://www.tc.cornell.edu:80/DX/DXTIPS/shadow.net.gif"> here. </a>
<p>
An example output from the program is shown below.
<p>
<!WA6><!WA6><!WA6><!WA6><!WA6><!WA6><!WA6><!WA6><!WA6><!WA6><!WA6><!WA6><!WA6><!WA6><!WA6><!WA6><img src="http://www.tc.cornell.edu:80/DX/DXTIPS/shadow.net.output.gif">
<p>
To download the macro click
<!WA7><!WA7><!WA7><!WA7><!WA7><!WA7><!WA7><!WA7><!WA7><!WA7><!WA7><!WA7><!WA7><!WA7><!WA7><!WA7><a href="http://www.tc.cornell.edu:80/DX/DXTIPS/shadow.macro.net">
here. </a>
<p>
Another example is shown below. A protein ribbon representation is casting
shadows on itself and on two planes.
<p>
<!WA8><!WA8><!WA8><!WA8><!WA8><!WA8><!WA8><!WA8><!WA8><!WA8><!WA8><!WA8><!WA8><!WA8><!WA8><!WA8><img src="http://www.tc.cornell.edu/~bruce/gifs/ShadowProtein.gif">
<hr>
See also:
<ul>
<li><!WA9><!WA9><!WA9><!WA9><!WA9><!WA9><!WA9><!WA9><!WA9><!WA9><!WA9><!WA9><!WA9><!WA9><!WA9><!WA9><a
href="http://www.tc.cornell.edu/ctc.html">
Cornell Theory Center</a>
<li><!WA10><!WA10><!WA10><!WA10><!WA10><!WA10><!WA10><!WA10><!WA10><!WA10><!WA10><!WA10><!WA10><!WA10><!WA10><!WA10><a
href="http://www.tc.cornell.edu/Visualization/animations/animations.html">
Examples of visualization work from CTC</a>
<li><!WA11><!WA11><!WA11><!WA11><!WA11><!WA11><!WA11><!WA11><!WA11><!WA11><!WA11><!WA11><!WA11><!WA11><!WA11><!WA11><a
href="http://www.tc.cornell.edu/Visualization/contrib/cs418-sp94/cs418.html">
CS418 final projects (spring 1994)</a>
<hr>
<!WA12><!WA12><!WA12><!WA12><!WA12><!WA12><!WA12><!WA12><!WA12><!WA12><!WA12><!WA12><!WA12><!WA12><!WA12><!WA12><IMG ALT="" SRC="http://www.tc.cornell.edu:80/Icons/ctc.logo.sm.gif">
<i>Cornell Theory Center.   (Last updated November 7, 1994 by 
<!WA13><!WA13><!WA13><!WA13><!WA13><!WA13><!WA13><!WA13><!WA13><!WA13><!WA13><!WA13><!WA13><!WA13><!WA13><!WA13><a
href="http://www.tc.cornell.edu/~bruce/">
Bruce Land)</i></a>

